clear
version 8.0
#delimit ;
cd "Z:\interactionmodels\";                       * SET WORKING DIRECTORY;
log using addresults\presidentialfig.log, replace;
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      presidentialfig.do                              *;
*       Date:           01/09/2007                                      *;
*       Author:         MRG                                             *;
*       Purpose:        Provide figure for effect of presidentialism    *;
*       Input File:     STATA_mozaffar.dta                              *;
*       Output File:    presidentialfig.do                              *;
*       Data Output:    none                                            *;
*       Previous file:                                                  *;
*       Machine:                                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;

use getdata\STATA_mozaffar.dta;


*     ****************************************************************  *;
*                  Presidential Figure for Electoral Parties            *;
*     ****************************************************************  *;

regress elecparties  fragmentation concentration logmag10 frag_conc logmag10_frag  
logmag10_conc logmag10_frag_conc proximity prescandidate prox_prescandidate, robust;

*     ****************************************************************  *;
*       Create x-axis for modifying variable (PRESCANDIDATE) = JH       *;
*     ****************************************************************  *;

generate JH=((_n-1)/10);    

replace JH=. if _n>80;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];
scalar b4=b[1,4];
scalar b5=b[1,5];
scalar b6=b[1,6];
scalar b7=b[1,7];
scalar b8=b[1,8];
scalar b9=b[1,9];
scalar b10=b[1,10];




scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar varb4=V[4,4];
scalar varb5=V[5,5];
scalar varb6=V[6,6];
scalar varb7=V[7,7];
scalar varb8=V[8,8];
scalar varb9=V[9,9];
scalar varb10=V[10,10];


scalar covb1b4=V[1,4];
scalar covb1b5=V[1,5];
scalar covb1b7=V[1,7];
scalar covb3b5=V[3,5];
scalar covb3b6=V[3,6];
scalar covb3b7=V[3,7];
scalar covb5b6=V[5,6];
scalar covb6b7=V[6,7];
scalar covb4b5=V[4,5];
scalar covb4b7=V[4,7];
scalar covb5b7=V[5,7];
scalar covb8b10=V[8,10];

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b8+b10*JH if _n<80;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb8+varb10*JH^2+2*covb8b10*JH)  if _n<80;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.01*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of proximity on electoral parties conditional  *;
*       on the number of presidential candidates                        *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5 6, labsize(2.5)) 
            ylabel(5 0 5  , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Estimated Causal Effect of Proximity") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black)) yline(-5 5, lcolor(white))  
            title("Estimated Causal Effect of Temporally-Proximate Presidential Elections", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Parties" " ", size(3))
            xtitle(Effective Number of Presidential Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Estimated Causal Effect of Proximity", size(3))
        scheme(s2mono) graphregion(fcolor(white));


drop JH conb top bottom a conse;

*     ****************************************************************  *;
*                               Save picture                            *;
*     ****************************************************************  *;

translate @Graph addresults\proximity.wmf, replace;

*     ****************************************************************  *;
*       Proximity never has a significant effect on the number of       *;
*       electoral parties.                                              *;
*     ****************************************************************  *;






*     ****************************************************************  *;
*                  Presidential Figure for Legislative Parties          *;
*     ****************************************************************  *;

regress legparties  fragmentation concentration logmag10 frag_conc logmag10_frag  
logmag10_conc logmag10_frag_conc proximity prescandidate prox_prescandidate, robust;

*     ****************************************************************  *;
*       Create x-axis for modifying variable (PRESCANDIDATE) = JH       *;
*     ****************************************************************  *;

generate JH=((_n-1)/10);    

replace JH=. if _n>80;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];
scalar b4=b[1,4];
scalar b5=b[1,5];
scalar b6=b[1,6];
scalar b7=b[1,7];
scalar b8=b[1,8];
scalar b9=b[1,9];
scalar b10=b[1,10];




scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar varb4=V[4,4];
scalar varb5=V[5,5];
scalar varb6=V[6,6];
scalar varb7=V[7,7];
scalar varb8=V[8,8];
scalar varb9=V[9,9];
scalar varb10=V[10,10];


scalar covb1b4=V[1,4];
scalar covb1b5=V[1,5];
scalar covb1b7=V[1,7];
scalar covb3b5=V[3,5];
scalar covb3b6=V[3,6];
scalar covb3b7=V[3,7];
scalar covb5b6=V[5,6];
scalar covb6b7=V[6,7];
scalar covb4b5=V[4,5];
scalar covb4b7=V[4,7];
scalar covb5b7=V[5,7];
scalar covb8b10=V[8,10];

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b8+b10*JH if _n<80;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb8+varb10*JH^2+2*covb8b10*JH)  if _n<80;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.01*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of proximity on Legislative Parties            *;
*       conditional on the number of presidential candidates            *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5 6, labsize(2.5)) 
            ylabel(5 0 5  , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Estimated Causal Effect of Proximity") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black)) yline(-5 5, lcolor(white))  
            title("Estimated Causal Effect of Temporally-Proximate Presidential Elections", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Legislative Parties" " ", size(3))
            xtitle(Effective Number of Presidential Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Estimated Causal Effect of Proximity", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
       
drop JH conb top bottom a;

*     ****************************************************************  *;
*                               Save picture                            *;
*     ****************************************************************  *;

translate @Graph addresults\proximity2.wmf, replace;

*     ****************************************************************  *;
*   Proximity has a negative and significant effect on the number of    *;
*   legislative parties so long as the number of presidential           *;
*   candidates is between 0.9 and 1.7. 18 observations out of 62 fall   *;
*   in this range.                                                      *;
*     ****************************************************************  *;

log close;
exit;
